﻿using System.Collections.Generic;
using UnityEngine;

namespace Framework
{
    public class UILayerName
    {
        public const int View = 0;

        public static readonly int[] AllName = new int[] { View };
    }

    public class UILayerFcatory
    {
        public delegate UILayer UILayerCreator(string name, RectTransform root);

        public static readonly Dictionary<int, UILayerCreator> MapType2creator =
            new Dictionary<int, UILayerCreator>()
            {
                {UILayerName.View, BaseUILayerCreator},
            };
        
        public static readonly string[] UILayerNames = new string[] {"View"};

        public static UILayer CreateUILayer(int layerName, RectTransform root)
        {
            string name = GetDesc(layerName);
            UILayer layer = MapType2creator[layerName](name, root);
            return layer;
        }
        
        public static string GetDesc(int layerName)
        {
            return UILayerNames[layerName];
        }

        private static UILayer BaseUILayerCreator(string name, RectTransform root)
        {
            return new UILayer(name, root);
        }
    }
}